import { createRouter, createWebHistory } from 'vue-router';
import Login from '../views/UserLogin.vue';
import Register from '../views/UserRegister.vue';
import TasteHome from '../views/TasteHome.vue';
import Community from '../views/Community.vue';
import PostInfo  from "../views/PostInfo.vue";
import DishList from "@/views/DishList.vue";
import Canteen from "@/views/Canteen.vue";
import OrderList from "@/views/OrderList.vue";
import CanteenInfo from "@/views/CanteenInfo.vue";
import UserInfo from "@/views/UserInfo.vue";
import ManageCanteen from "@/views/ManageCanteen.vue";
import ManageUser from "@/views/ManageUser.vue";
import ManageOrder from "@/views/ManageOrder.vue";
import ManageCommunity from "@/views/ManageCommunity.vue";
import Manage from "@/views/Manage.vue";
import ManageInfo from "@/views/ManageInfo.vue";

const routes = [
    {
      path: '/test',
      name: 'test',
      component: () => import('../views/test.vue'),
    },
    // {
    //     path: '/pay',
    //     name: 'Pay',
    //     component: () => import('../views/pay.vue'),
    // },
    {
        path: '/manageInfo',
        name: 'manageVue',
        component: Manage,
    },
    {
        path: '/manage/user',
        component: ManageUser
    },
    {
        path: '/manage/canteen',
        component: ManageCanteen
    },
    {
        path: '/userInfo',
        name: 'UserInfo',
        component: UserInfo,
    },{
        path: '/manage/info',
        name: 'ManageInfo',
        component: ManageInfo,
    },
    {
        path: '/tasteHome',
        name: 'TasteHome',
        component: TasteHome,
    },
    {
        path: '/community',
        name: 'Community',
        component: Community,
    },{
        path: '/manage/community',
        name: 'ManageCommunity',
        component: ManageCommunity,
    },
    {
        path: '/postInfo/:postId',
        name: 'PostInfo',
        component: PostInfo,
    },
    {
        path: '/',
        redirect: '/login',
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/register',
        name: 'Register',
        component: Register
    },
    // {
    //     path: '/admin',
    //     name: 'AdminInfo',
    //     component: AdminInfo,
    // },
    {
        path: '/dish-list',
        name: 'DishList',
        component: DishList,
        props: true, // 使路由参数作为 prop 传递给组件
    },
    {
        path: '/canteen',
        name: 'CanteenList',
        component: Canteen,
        props: true,
    },
    {
        path: '/order',
        name: 'OrderListVue',
        component: OrderList,
        props: true,
    },
    {
        path: '/manage/modules',
        name: 'ManageOrder',
        component: ManageOrder,
        props: true,
    },
    {
        path: '/canteenInfo/:canteenId', // 动态参数 :canteenId
        name: 'CanteenInfoVue',
        component: CanteenInfo,
        props: true,
    }
];

const router = createRouter({
    history: createWebHistory(),
    routes
});

export default router;
